project (libxblt)

enable_testing ()

# Read VERSION information
FILE (READ "VERSION" VERSION)
STRING (REPLACE "\n" "" XBLF_VERSION ${VERSION})
STRING(COMPARE EQUAL "${XBLF_VERSION}" "SVN" IS_DEVELOPER_BUILD)
IF (IS_DEVELOPER_BUILD) 
    SET (XBLF_VERSION_LONG  "libxblt v${XBLF_VERSION}")
    SET (XBLF_VERSION_SHORT "v${XBLF_VERSION}")
    SET (XBLF_VERSION_MAJOR "0")
    SET (XBLF_VERSION_MINOR "0")
    SET (XBLF_VERSION_REVISION "0")
ELSE (IS_DEVELOPER_BUILD)
    STRING (REGEX REPLACE "([0-9]+)[.]([0-9]+)[.](.*)$" "\\1" XBLF_VERSION_MAJOR ${XBLF_VERSION})
    STRING (REGEX REPLACE "([0-9]+)[.]([0-9]+)[.](.*)$" "\\2" XBLF_VERSION_MINOR ${XBLF_VERSION})
    STRING (REGEX REPLACE "([0-9]+)[.]([0-9]+)[.](.*)$" "\\3" XBLF_VERSION_REVISION ${XBLF_VERSION})
    SET (XBLF_VERSION_LONG  "libxblt v${XBLF_VERSION}")
    SET (XBLF_VERSION_SHORT "v${XBLF_VERSION}")
ENDIF (IS_DEVELOPER_BUILD)

CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/include/xblf_version.h.in 
                ${CMAKE_CURRENT_BINARY_DIR}/xblf_version.h
                ESCAPE_QUOTES)

set (CMAKE_BUILD_TYPE debug)

find_package (CURL REQUIRED)
find_package (LibXml2 REQUIRED)

include_directories (include)
include_directories (${CURL_INCLUDE_DIR})
include_directories (${LIBXML2_INCLUDE_DIR})
include_directories (${CMAKE_CURRENT_BINARY_DIR})
link_directories    (${CURL_LIBRARIES})
link_directories    (${LIBXML2_LIBRARIES})
link_libraries      (${LIBXML2_LIBRARIES} ${CURL_LIBRARIES} xblf)

add_subdirectory (src)
add_subdirectory (examples)
add_subdirectory (tests)
